package cn.hncj.lyc.controller.back;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.hncj.lyc.bean.AdvertisementManagement;
import cn.hncj.lyc.service.AdvertisementManagementService;

@Controller
@RequestMapping("/back/")
public class AdvertiseManagementController {
	    
	
	 @Autowired
	 private AdvertisementManagementService  advertManSer;
	      @RequestMapping("advertisemanagement")
           public String AdvertiseManagement() {
        	   return "back/advertisementmanagement/advertisement_management";
			
		}
	      
	      @RequestMapping("addadvertisement")
          public String addAdvertise(AdvertisementManagement advertisementmanagement,Model model) {
	    	 
	    	  try {
	    	   advertManSer.addAdvertisement(advertisementmanagement);
	  			model.addAttribute("result", "添加广告成功");
	  		} catch (Exception e) {
	  			// TODO Auto-generated catch block
	  			e.printStackTrace();
	  			model.addAttribute("result", "添加广告失败");
	  		}
	    	  return "back/advertisementmanagement/advertisement_info";
	 
	  	}
       	   
		
	      @RequestMapping("deleteadvertisement")
          public String showAdvertise(AdvertisementManagement advertisementmanagement,Model model) {
	    	 
	    	  try {
		    	   advertManSer.deleteAdvertisement(advertisementmanagement);
		  		  
	    		  model.addAttribute("result", "删除成功");
		  		} catch (Exception e) {
		  			// TODO Auto-generated catch block
		  			e.printStackTrace();
		  			model.addAttribute("result", "删除失败");
		  		}
	    	  return "back/advertisementmanagement/advertisement_info";
		  	}
	    	  
       
}
